import { request } from '../request'
import type { Address, CreateAddressRequest } from '@/types'

// 获取地址列表
export const getAddressList = (): Promise<Address[]> => {
    return request.get('/api/user-service/api/user/address/list')
}

// 创建地址
export const addAddress = (data: CreateAddressRequest): Promise<void> => {
    return request.post('/api/user-service/api/user/address', data)
}

// 更新地址
export const updateAddress = (id: number, data: CreateAddressRequest): Promise<void> => {
    return request.put(`/api/user-service/api/user/address/${id}`, data)
}

// 删除地址
export const deleteAddress = (id: number): Promise<void> => {
    return request.delete(`/api/user-service/api/user/address/${id}`)
}

// 设置默认地址
export const setDefaultAddress = (id: number): Promise<void> => {
    return request.put(`/api/user-service/api/user/address/${id}/default`)
}
